package com.huluobo.a2203kotlinshopping.RoomDemo

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.Toast
import com.huluobo.a2203kotlinshopping.R
import com.huluobo.a2203kotlinshopping.databinding.ActivityRoomBinding

class RoomActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        val activityRoomBinding = ActivityRoomBinding.inflate(layoutInflater)
        setContentView(activityRoomBinding.root)


        activityRoomBinding.roomBtn.setOnClickListener {
            val loginBean = LoginBean(
                0,
                activityRoomBinding.roomUsername.text.toString(),
                activityRoomBinding.roomPassword.text.toString()
            )
            AppDBUtils.getDb().loginDao.insertUserInfo(loginBean)
        }

        activityRoomBinding.roomQuery.setOnClickListener {
            val queryUserInfo = AppDBUtils.getDb().loginDao.queryUserInfo()
            Toast.makeText(this, "$queryUserInfo", Toast.LENGTH_LONG).show()
        }
    }
}